package com.bjmashibing.system.OSFileIO.io_demo.ReaderOrWriter;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class ReaderDemo {

    public static void main(String[] args) throws IOException {
        demo1();
        demo2();

    }


    public static void demo1() throws IOException {
        Reader reader=new FileReader("src/Java_IO/io_demo/Resources/abc.txt");
        int read = Integer.MIN_VALUE;
        while ((read=reader.read())!=-1){
            System.out.println((char) read);
        }
        reader.close();
    }

    public static void demo2() throws IOException {
        Reader reader=new FileReader("src/Java_IO/io_demo/Resources/abc.txt");
        int length= Integer.MIN_VALUE;
        char[] chars=new char[1024];
        while ((length=reader.read(chars))!=-1){
            System.out.println(new String(chars,0,length));
        }
        reader.close();
    }


}
